use util::{GitRepo, HgRepo, CargoResult, human, ChainError, internal};
use util::Config;
+use toml;
+
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum VersionControl { Git, Hg, NoVcs }
r#"[package]
name = "{}"
version = "0.1.0"
-authors = ["{}"]
-"#, name, author).as_bytes()));
+authors = [{}]
+"#, name, toml::Value::String(author)).as_bytes()));
try!(fs::create_dir(&path.join("src")));
assert!(contents.contains(r#"authors = ["foo"]"#));
});
+test!(finds_author_user_escaped {
+ // Use a temp dir to make sure we don't pick up .cargo/config somewhere in
+ // the hierarchy
+ let td = TempDir::new("cargo").unwrap();
+ assert_that(cargo_process("new").arg("foo").env("USER", "foo \"bar\"")
+ .cwd(td.path().clone()),
+ execs().with_status(0));
+
+ let toml = td.path().join("foo/Cargo.toml");
+ let mut contents = String::new();
+ File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
+ assert!(contents.contains(r#"authors = ["foo \"bar\""]"#));
+});
+
test!(finds_author_username {
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
// the hierarchy